package link.luyu.protocol.link.sipc;

import com.simplechain.link.SipcConnection;
import com.simplechain.link.SipcDriver;

import java.util.Map;

import link.luyu.protocol.link.Connection;
import link.luyu.protocol.link.Driver;
import link.luyu.protocol.link.LuyuPlugin;
import link.luyu.protocol.link.PluginBuilder;

@LuyuPlugin("Sipc")
public class SipcPluginBuilder extends PluginBuilder {
    @Override
    public Connection newConnection(Map<String, Object> properties) {
        try {
//            com.simplechain.util.Utils.saveFile("", "newConnection" + properties.toString(), true);
            return new SipcConnection(properties);
        } catch (Exception e) {
            System.out.println("SipcPluginBuilder newConnection exception: " + e.getMessage());
            return null;
        }
    }

    @Override
    public Driver newDriver(Connection connection, Map<String, Object> properties) {
        try {
//            com.simplechain.util.Utils.saveFile("", "newDriver" + properties.toString(), true);
            return new SipcDriver(connection, properties);
        } catch (Exception e) {
            System.out.println("SipcPluginBuilder newDriver exception: " + e.getMessage());
            return null;
        }
    }
}
